package org.example.struct.array2;

/**
 * @author liyishan
 * @date 2024/3/8 11:03
 * @apiNote
 */

public class Test02834MinimumPossibleSum {

    public static void main(String[] args) {
        System.out.println(minimumPossibleSum(3, 12));
    }


    public static int minimumPossibleSum(int n, int target) {
        final int mod = (int) 1e9 + 7;
        int m = target / 2;
        if (n <= m) {
            return (int) ((long) (1 + n) * n / 2 % mod);
        }
        return (int) (((long) (1 + m) * m / 2 +
                ((long) target + target + (n - m) - 1) * (n - m) / 2) % mod);

    }
}
